co2 = coroutine.create(
        function()
            for i = 1, 10 do
                print(i)
                if ( i == 3) then
                    print(coroutine.status(co2))
                    print(coroutine.running())
                end
                coroutine.yield()
            end
        end
)

coroutine.resume(co2)
coroutine.resume(co2)
coroutine.resume(co2)

print(coroutine.status(co2))
print(coroutine.running())
print("_________________________")


-- 协程进阶
function foo(a)
    print("foo函数输出", a)
    return coroutine.yield(2*a)
end



co = coroutine.create(
        function(a,b)
            print("第一次携程输出",a,b)
            local r = foo(a + 1)
            print("第二次执行程序输出",r)
            coroutine.yield(a + 1,a - b)
            print("第三次执行程序输出",r,s)

            return b,"结束"
        end
)

print("main",coroutine.resume(co,1,10))
print("main",coroutine.resume(co,"x","y"))
print("main",coroutine.resume(co,"r"))